package com.lulu.landslidedemo04;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.List;

/**
 * Created by zhanglulu on 2017/3/28.
 * 不可滚动的ListView的Adapter
 */

public class NoScrollListViewAdapter<T> extends BaseAdapter {
    private volatile List<T> mList;
    private Context mContext;
    private BaseLandSlideAdapter<T> mSlideAdapter;

    public NoScrollListViewAdapter(Context context, BaseLandSlideAdapter<T> slideAdapter) {
        mContext = context;
        mSlideAdapter = slideAdapter;
    }

    @Override
    public int getCount() {
        if (mList == null) {
            return 0;
        }
        synchronized (mList) {
            int count = mList.size();
            return count;
        }
    }

    @Override
    public T getItem(int i) {
        return mSlideAdapter.getItem(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return mSlideAdapter.getView(position, convertView, parent);
    }

    @Override
    public int getItemViewType(int position) {
        return mSlideAdapter.getItemViewType(position);
    }

    @Override
    public int getViewTypeCount() {
        return mSlideAdapter.getViewTypeCount();
    }

    ///////////////////////////////////////////////////////////////////////////
    // 对外开放的方法
    ///////////////////////////////////////////////////////////////////////////


    public void setList(List<T> list) {
        this.mList = list;
        notifyDataSetChanged();
    }

}
